<?php
/**
 * 订单
 */
namespace App\Controller\Goods;

use Common\Controller\App\CommonController;
use Common\Model\LogisticsTempConModel;
use Common\Model\MemberAddressModel;
use Common\Model\MemberModel;
use Common\Model\MicroShopCouponsModel;
use Common\Model\OrderLogModel;
use Common\Model\OrderModel;
use Common\Model\OrderProductModel;
use Common\Model\PaymentTypeModel;
use Common\Model\ProductCartModel;
use Common\Model\ProductSkuModel;
use Common\Model\StockShopsModel;
use Common\Model\StockStocksModel;
use Common\Model\StockSupplieProductsModel;
use Common\Model\TarentoCashFlowModel;
use Common\Model\TarentoModel;

class OrderController extends CommonController{

    /**
     * 订单添加并支付
     */
    public function order_add(){
        $addressId  = I('post.addressId');  //收货地址
        $cash_price = I('post.money')?I('post.money'):0; //使用的金额
        $isUseCash  = I('post.isUseCash')?I('post.isUseCash'):0; //1表示使用余额
        $payPwd     = I('post.payPwd'); //支付密码
        $cpns_id    = I('post.cpns_id'); //代金券id
        $payTypeId  = I('post.payTypeId')?I('post.payTypeId'):2; //支付类型id   1支付宝 2微信
        $member_id  = session('member_id');
        $supplier_id = I('post.supplier_id');  //直接购买使用
        $warehouse_type = I('post.warehouse_type'); //直接购买使用
        $skuIds     = I('post.skuIds'); //商品id  //直接购买使用
        $active_id     = I('post.active_id'); //  活动  3  //直接购买使用

        if($isUseCash==1){
            $model = new TarentoModel();
            $payPwd = $model->getPayPwdEncode($payPwd);
            $info = $model->verification_pay_pwd($member_id,$payPwd);
            if(empty($info)){
                $this->ajaxReturn(['code'=>300,'msg'=>'您好，请输入正确的支付密码']);
            }
            if($cash_price>$info['account']){
                $this->ajaxReturn(['code'=>300,'msg'=>'您好，您的账户余额不足']);
            }
        }
        //获取购物车商品
        $cart_model = new ProductCartModel();
        //$cart_info = $cart_model->cartSkuList($member_id,$skuIds);
        $model = new MemberModel();
        $member_info = $model->where("userid=$member_id")->find();
        if(empty($member_info['mobile'])){
            return ['code'=>300,'msg'=>'你还没有绑定手机号'];
        }
        //and c.product_id in ($skuIds)
        if($skuIds){
            $model = new ProductSkuModel();
            $list = $model->where("id=$skuIds")->field("pname,ms_price,pic,stock_shop,id as skuid,ms_stock_supplierid,ms_entrepot_supplierid,ms_direct_supplierid,spec,catid,pic,ms_discount,ms_taxation,pa.weight")->select();
        }else{
            $list = $cart_model->alias('c')->join("left join haiou_product_sku as pa on pa.id=c.product_id")->where("c.status>0 and c.active_id!=3 and c.member_id=$member_id ")->field("c.num,pa.pname,pa.ms_price,pa.pic,c.stock_shop,c.id,pa.id as skuid,pa.ms_stock_supplierid,pa.ms_entrepot_supplierid,pa.ms_direct_supplierid,pa.spec,pa.catid,pa.pic,pa.ms_discount,pa.ms_taxation,c.supplier_id,c.active_id,c.warehouse_type,pa.weight")->select();
        }
        foreach($list as $v){
            $pic = explode(',',$v['pic']);
            $v['pic'] = $pic;
            if($supplier_id){
                $v['supplier_id'] = $supplier_id;

            }
            if($warehouse_type){
                $v['warehouse_type'] = $warehouse_type;

            }
            if(empty($v['num'])){
                $v['num'] = 1;
            }
            if($active_id==3){
                $v['active_id'] = 3;
            }
            $lists[$v['stock_shop']]['list'][] = $v;
        }
        if(empty($lists)){
            $lists = [];
        }

        $ms_Freight_risk = 0;
        $s_array = [];
        $total_money1 = 0; //商品总价格
        $total_ms_taxation = 0; //商品总税费
        $free_money = 0; //总运费
        $ms_discount1 = 0; //总的折扣价
        $weight = 0;  //商品总重量
        $stockShopId = 0;
        foreach($lists as $k=>$v){
            $total_money = 0;
            $ms_taxation = 0;
            $ms_discount = 0;
            $model = new StockShopsModel();
            $info = $model->getInfoById($k);  //根据仓库id查询当前仓库信息
            $lists[$k]['title'] = $info['show_title'];
            $lists[$k]['free'] = $info['free'];  //满多少包邮
            //$lists[$k]['free_money'] = $info['default_price'];  //运费
            $lists[$k]['logisticsId'] = $info['logisticsid'];
            $lists[$k]['weight'] = 0;

            foreach($v['list'] as $y=>$x){
                $total_money += $x['ms_price']*$x['num'];
                $lists[$k]['list'][$y]['logisticsid'] = $info['logisticsid'];
                $ms_taxation += $x['ms_taxation']*$x['num'];   //当前仓库商品税费
                $ms_discount += $x['ms_discount']*$x['num'];   //当前仓库商品税费
                $lists[$k]['weight'] += $x['weight']*$x['num'];   //当前仓库商品税费
            }
            $lists[$k]['total_price'] = $total_money;
            $lists[$k]['ms_taxation'] = $ms_taxation;  //税费
            $lists[$k]['ms_discount'] = $ms_discount;  //总的折扣价
            $total_ms_taxation += $ms_taxation;

            $lists[$k]['ms_Freight_risk'] = 0;  //运费险
            if($lists[$k]['total_price'] <=200 ){
                $lists[$k]['ms_Freight_risk'] = 1;
            }elseif($lists[$k]['total_price'] >200  && $lists[$k]['total_price'] <= 300){
                $lists[$k]['ms_Freight_risk'] = 2;
            }elseif($lists[$k]['total_price'] > 300){
                $lists[$k]['ms_Freight_risk'] = 3;
            }
            $lists[$k]['free_money'] = 0; //运费
            if($total_money<$info['free']){
                if(!in_array($info['logisticsid'],$s_array)){
                    $s_array[] = $info['logisticsid'];
                    $lists[$k]['free_money'] = $info['default_price'];

                }else{
                    $s_array[] = $info['logisticsid'];
                }
                //$lists[$k]['free_money'] = $free_money;
                //$lists[$k]['total_price'] += $lists[$k]['free_money'];
                //$lists[$k]['total_price'] += $lists[$k]['ms_Freight_risk'];
            }else{
                //$lists[$k]['total_price'] += $lists[$k]['ms_Freight_risk'];
            }
            $total_money1 += $lists[$k]['total_price'];
            $ms_Freight_risk += $lists[$k]['ms_Freight_risk'];
            $free_money +=  $lists[$k]['free_money'];
            $ms_discount1 +=  $lists[$k]['ms_discount'];
            $weight +=  $lists[$k]['weight'];
            $stockShopId = $k;
        }
        //$cart_info = $cart_model->cart_list($member_id);
        //$cart_info = $cart_info['list'];
        //$total_money = $cart_info['total_money'];

        //获取代金券数据
        if($cpns_id){
            $cpnsModel = new MicroShopCouponsModel();
            $cpns_info = $cpnsModel->getOne($cpns_id);
            if($cpns_info){
                if(time()>=strtotime($cpns_info['start_time'] && time()<=strtotime($cpns_info['end_time']))){

                }else{
                    $this->ajaxReturn(['code'=>300,'msg'=>'代金券已过期']);
                }

            }else{
                $this->ajaxReturn(['code'=>300,'msg'=>'此代金券不存在']);
            }
        }

        // 生成订单号
        $d=getdate();
        $prefix= date('y');
        $prefix.=str_pad($d['yday'],3,0,STR_PAD_LEFT);
        $prefix.= str_pad(time()- strtotime(date('Y-m-d')),5,0,STR_PAD_LEFT);
        $order_id=$prefix.str_pad(substr($member_id,-5,5),5,0,STR_PAD_LEFT).rand(0,9);

        //获取收货地址
        $addressModel = new MemberAddressModel();
        $address_info = $addressModel->where("userid=$member_id and id=$addressId")->find();
        if(empty($address_info)){
            $this->ajaxReturn(['code'=>300,'msg'=>'收货地址不存在']);
        }

        //获取支付类型
        $payTypeModel = new PaymentTypeModel();
        $payMentInfo = $payTypeModel->where("payment_id=$payTypeId")->find();

        $orderType = 3;//订单类型,微店订单
        //获取用户订单数量
        //$orderNum = (new \App\Models\Order())->getNumByMemberId($member_id);
        $op_model = new OrderProductModel(); //订单商品表
        if(count($lists)>1){
            $separate_status = 1;
        }else{
            $separate_status = 0;
        }
        foreach ($lists as $key=>$vo){

            //计算优惠券和折扣占商品总额的比例，以计算实际需要调价的值（暂时只有优惠券）
//            $discountRate = $vo["cpns_price"] >0 ? (1 - $vo["cpns_price"]/$vo["total_price"]) : 1;
            foreach($vo['list'] as $d){
                //写入订单商品表
                $orderProCreateData = [
                    'member_id'	    => $member_id,
                    'order_id'		=> $order_id,
                    'product_id'    =>$d['skuid'],
                    'supplier_id'   =>$d['supplier_id'],
                    'product_name'  =>$d['pname'],
                    'property'      =>$d['spec'],
                    'pcatid'        =>$d['catid'],
                    'pic'           =>$d['pic'][0],
                    'price'         =>$d['ms_price'],
                    'ms_discount'   =>$d['ms_discount'],
                    'num'           =>$d['num'],
                    'logisticsId'   =>$d['logisticsid'],
                    'stock_shop'    =>$d['stock_shop'],
                    'active_id'     =>$d['active_id'],
                    'tax_price'     =>$d['ms_taxation']
                ];


                $id = $op_model->add($orderProCreateData);
                if(empty($id)){
                    //$this->ajaxReturn(['code'=>300,'msg'=>'创建订单商品失败']);
                }
                //减库存,增加销量
                if ($d['num']>0) {
                    $model = new StockSupplieProductsModel();
                    //$model->updateStocks($d['skuid'],$d['num'],$d['supplier_id']);
                    /*if ($d['supplier_id'] == 0) {//自营
                        $model = new StockStocksModel();
                        $model->updateSoldNum($cart_info['stockShopId'],$d['product_id'], $d['num']);
                        $model = new ProductSkuModel();
                        $model->updateStocksAndSellAmount($cart_info['stockShopId'],$d['product_id'], $d['num']);
                    } else {
                        $model = new StockSupplieProductsModel();
                        $model->updateStocks($d['product_id'],$d['num'],$d['supplier_id']);
                    }*/
                }

                //清除购物车中该商品
                $cart_model->where("member_id=$member_id and id=".$d['id'])->delete();
                $warehouseType = $d['warehouse_type'];
            }
        }
        $cpns_then = $cpns_info['cpns_then']?$cpns_info['cpns_then']:0;
        $cpns_then_id = $cpns_info['id']?$cpns_info['id']:0;
        $orderCreateData = [
            'member_id'	        => $member_id,
            'order_id'			=> $order_id,
            //'master_order_id'   => $order_id,
            'ms_id'              => self::$shop_id,
            'order_time'		    => time(),
            'order_type'         => $orderType,
            'payment_id'		    => $payTypeId,
            'payment_name'       => (string)$payMentInfo['payment_name'],
            'shipping_id'        => $info['id'],
            'warehouse_type'     => $warehouseType,
            'shipping_name'      => $info['show_title'],
            'ship_name'          => (string)$address_info['name'],
            'ship_addr'          => (string)$address_info['area'],
            'ship_mobile'        => $address_info['mobile'],
            'shipping_idcard'    => (string)$address_info['idcard'],
            'ship_zip'           => $address_info['zip'],
            'cpns_price'         => $cpns_then,
            'cpns_id'            => $cpns_then_id,
            'cash_price'         => $cash_price,
            'cost'               => $total_money1,
            'ms_discount'        => $ms_discount1,
            'freight'            => $free_money,
            'tax_price'          => 0,
            'weight'             => $weight,
            'separate_status'    => $separate_status,
            'stock_shop'         => $stockShopId,
            'client_system'      => 3,
            'client_platform'    => 4,
            'total_ms_taxation'  => $total_ms_taxation,
            'ms_Freight_risk'    => $ms_Freight_risk,
            'active_id'          => 0
        ];

        $model = new OrderModel();
        $order_num = 1;
        $cpns_then = $cpns_info['cpns_then']?$cpns_info['cpns_then']:0;
        $cost_total = $total_money1-$cpns_then<0?0:$total_money1-$cpns_then;
        $order_total_money = $ms_Freight_risk+$cost_total+$total_ms_taxation+$free_money-$cash_price;

        //$op_model->where("order_id=$order_id")->delete();
        $order_info_id = $model->add($orderCreateData);
        if($order_info_id){
            /*if(count($lists)>1){
                $ms_Freight_risk = 0;
                $s_array = [];
                $total_money1 = 0; //商品总价格
                $total_ms_taxation = 0; //商品总税费
                $free_money = 0; //总运费
                $ms_discount1 = 0; //总的折扣价
                $weight = 0;  //商品总重量
                $stockShopId = 0;
                foreach($lists as $k=>$v){
                    $total_money = 0;
                    $ms_taxation = 0;
                    $ms_discount = 0;
                    $stmodel = new StockShopsModel();
                    $info = $stmodel->getInfoById($k);  //根据仓库id查询当前仓库信息
                    $lists[$k]['title'] = $info['show_title'];
                    $lists[$k]['free'] = $info['free'];  //满多少包邮
                    $lists[$k]['logisticsId'] = $info['logisticsid'];
                    $lists[$k]['weight'] = 0;

                    foreach($v['list'] as $y=>$x){
                        $total_money += $x['ms_price']*$x['num'];
                        $v['list'][$y]['logisticsid'] = $info['logisticsid'];
                        $ms_taxation += $x['ms_taxation']*$x['num'];   //当前仓库商品税费
                        $ms_discount += $x['ms_discount']*$x['num'];   //当前仓库商品税费
                        $lists[$k]['weight'] += $x['weight']*$x['num'];   //当前仓库商品税费
                        $warehouse_type = $x['warehouse_type'];
                    }

                    $lists[$k]['total_price'] = $total_money;
                    $lists[$k]['ms_taxation'] = $ms_taxation;  //税费
                    $lists[$k]['ms_discount'] = $ms_discount;  //总的折扣价
                    $total_ms_taxation += $ms_taxation;

                    $lists[$k]['ms_Freight_risk'] = 0;  //运费险
                    if($lists[$k]['total_price'] <=200 ){
                        $lists[$k]['ms_Freight_risk'] = 1;
                    }elseif($lists[$k]['total_price'] >200  && $lists[$k]['total_price'] <= 300){
                        $lists[$k]['ms_Freight_risk'] = 2;
                    }elseif($lists[$k]['total_price'] > 300){
                        $lists[$k]['ms_Freight_risk'] = 3;
                    }
                    $lists[$k]['free_money'] = 0; //运费
                    if($total_money<$info['free']){
                        if(!in_array($info['logisticsid'],$s_array)){
                            $s_array[] = $info['logisticsid'];
                            $lists[$k]['free_money'] = $info['default_price'];

                        }else{
                            $s_array[] = $info['logisticsid'];
                        }
                        //$lists[$k]['free_money'] = $free_money;
                        //$lists[$k]['total_price'] += $lists[$k]['free_money'];
                        //$lists[$k]['total_price'] += $lists[$k]['ms_Freight_risk'];
                    }else{
                        //$lists[$k]['total_price'] += $lists[$k]['ms_Freight_risk'];
                    }
                    $total_money1 += $lists[$k]['total_price'];
                    $ms_Freight_risk += $lists[$k]['ms_Freight_risk'];
                    $free_money +=  $lists[$k]['free_money'];
                    $ms_discount1 +=  $lists[$k]['ms_discount'];
                    $weight +=  $lists[$k]['weight'];
                    $order_id_sn = $order_id.$order_num;
                    if($order_num==1){
                        $cpns_then = $cpns_info['cpns_then']?$cpns_info['cpns_then']:0;
                        $cpns_then_id = $cpns_info['id']?$cpns_info['id']:0;
                    }else{
                        $cpns_then = 0;
                        $cpns_then_id=0;
                    }
                    $cash_price_num = count($lists);
                    $cash_price = sprintf("%.2f", $cash_price/$cash_price_num);
                    $orderCreateData = [
                        'member_id'	        => $member_id,
                        'order_id'			=> $order_id_sn,
                        'master_order_id'   => $order_id,
                        'ms_id'              => self::$shop_id,
                        'order_time'		    => time(),
                        'order_type'         => $orderType,
                        'payment_id'		    => $payTypeId,
                        'payment_name'       => (string)$payMentInfo['payment_name'],
                        'shipping_id'        => $info['id'],
                        'warehouse_type'     => $warehouse_type,
                        'shipping_name'      => (string)$info['show_title'],
                        'ship_name'          => (string)$address_info['name'],
                        'ship_addr'          => (string)$address_info['area'],
                        'ship_mobile'        => $address_info['mobile'],
                        'shipping_idcard'    => (string)$address_info['idcard'],
                        'ship_zip'           => $address_info['zip'],
                        'cpns_price'         => $cpns_then,
                        'cpns_id'            => $cpns_then_id,
                        'cash_price'         => $cash_price,
                        'cost'               => $v['total_price'],
                        'ms_discount'        => $ms_discount1,
                        'freight'            => $v['free_money'],
                        'tax_price'          => 0,
                        'weight'             => $v['weight'],
                        'separate_status'    => 0,
                        'stock_shop'         => $k,
                        'client_system'      => 3,
                        'client_platform'    => 4,
                        'total_ms_taxation'  => $v['ms_taxation'],
                        'ms_Freight_risk'    => $v['ms_Freight_risk'],
                        'active_id'          => 0
                    ];
                    $model = new OrderModel();
                    $id = $model->add($orderCreateData);
                   // echo $id.'<br/>';
                    $order_num++;
                    foreach($v['list'] as $d){
                        //写入订单商品表
                        $op_model = new OrderProductModel();
                        $orderProCreateData1 = [
                            'member_id'	    => $member_id,
                            'order_id'		=> $order_id_sn,
                            'product_id'    =>$d['skuid'],
                            'supplier_id'   =>$d['supplier_id'],
                            'product_name'  =>$d['pname'],
                            'property'      =>$d['spec'],
                            'pcatid'        =>$d['catid'],
                            'pic'           =>$d['pic'][0],
                            'price'         =>$d['ms_price'],
                            'ms_discount'   =>$d['ms_discount'],
                            'num'           =>$d['num'],
                            'logisticsId'   =>$d['logisticsid'],
                            'stock_shop'    =>$d['stock_shop'],
                            'active_id'     =>$d['active_id'],
                            'tax_price'     =>$d['ms_taxation']
                        ];
                        $op_model->add($orderProCreateData1);
                    }
                }

            }*/
            $order_total_money = 0.01;
            if($cash_price>=$order_total_money){
                $model = new TarentoModel();
                $tarento_info = $model->where("member_id=$member_id")->field("account")->find();
                $result = $model->where("member_id=$member_id")->save(['account'=>$tarento_info['account']-$cash_price]);
                $tcf_model = new TarentoCashFlowModel();
                $tcf_data['member_id'] = $member_id;
                $tcf_data['price'] = -$cash_price;
                $tcf_data['type_code'] = 'SET_ORDER';
                $tcf_data['description'] = "下单支付，订单号：$order_id";
                $tcf_data['extension'] = $order_id;
                $tcf_data['create_time'] = date('Y-m-d H:i:s',time());
                $tcf_model->add($tcf_data);
                if($result){
                    $orderModel = new OrderModel();
                    $order_info = $orderModel->where("order_id=$order_id")->find();
                    $belondShopId = $order_info['ms_id'];
                    $pay_status   = $order_info['pay_status'];
                    $order_type   = $order_info['order_type'];
                    $allMoney = $order_info['cost'] + $order_info['cpns_price'] + $order_info['freight'] + $order_info['ms_Freight_risk'] + $order_info['total_ms_taxation'];

                    if ($pay_status == 1)//如果是支付订单的情况
                    {
                        //查看是否有多订单
                        $orderModel = new OrderModel();
                        $orderModel->order_see($order_id);

                    }
                    //处理库存的
                    $model = new OrderProductModel();
                    $re = $model->join("left join haiou_product_sku as b on a.product_id=b.id")->where("a.order_id='$out_trade_no'")->field("a.product_id,a.num as nums,a.microstock_num,a.price,a.member_id,a.active_id,b.stock_relations")->select();
                    // 获取全返活动的产品ID集合
                    $commonOrderTotal = 0;

                    foreach ($re as $val) {
//
                        $commonOrderTotal += $val['price'] * $val['nums'];
                    }
                    //查询用户是否使用优惠券结算
                    $model = new OrderModel();
                    $strs = $model->where("order_id='$out_trade_no'")->find();
                    if ($strs['cpns_price'] > 0) {
                        $commonOrderTotal = $commonOrderTotal - $strs['cpns_price'];
//
                    }

                    // 查看是否是第一单
                    $model = new OrderModel();
                    $orderNum = $model->where("status>1 and pay_status>1 and active_id != 3 and member_id=$member_id and master_order_id=''")->field("COUNT(member_id) AS total_num")->find();
                    $orderNum = $orderNum['total_num'];

                    // 如果购买了普通区产品，并且是第一单，则可以参与99返活动
                    if ($commonOrderTotal > 0 && $orderNum['total_num'] <= 1) {
                        $quanfanOrderData = [
                            'memberId' => $member_id,
                            'orderId' => $out_trade_no,
                            'shopId' => $belondShopId,
                            'orderType' => 2,
                            'price' => $commonOrderTotal
                        ];

                        // TODO: test
                        $env = RUN_ENV;
                        $model = new OrderLogModel();
                        $model->add(['order_id'=>$out_trade_no,'admin_id'=>'','admin_name'=>'','text'=>"testxxxx:{$env}commonOrderTotal",'behavior'=>'付款','result'=>'success']);
                        // 添加全返订单
                        $model = new QuanfanModel();
                        $model->addOrder($quanfanOrderData);
                    }

                    if ($order_type < 3) {//微店订单不参与合伙人结算
                        //放入返利处理队列
                        // include_once("$config[webroot]/lib/Httpsqs.php");
                        // Httpsqs::put('tarentoOrder', array('order_id' => $out_trade_no));
                    } else {

                        // TODO: test
                        $env = RUN_ENV;
                        $model = new OrderLogModel();
                        $model->add(['order_id'=>$out_trade_no,'admin_id'=>'','admin_name'=>'','text'=>'payment_class.php 610-line','behavior'=>'付款','result'=>'success']);

                        //给用户推送消息
                        $replaceArr = [];
                        //订单商品信息
                        $model = new OrderProductModel();
                        $productName = $model->where("order_id='$out_trade_no'")->field("product_name")->find();
                        $productName = $productName['product_name'];

                        //查询订单支付总金额

                        $param = [
                            'memberId' => $re['member_id'],
                            'orderProductPrice' => $allMoney,
                            'orderProductName' => $productName,
                            'orderAddress' => $re['ship_name'] . ',' . $re['ship_addr'],
                            'orderName' => $out_trade_no,
                            'url' => 'http://wx.52ywy.com/?shop=' . $re['ms_id'] . '#&cart/orderdetail/?id=' . $out_trade_no
                        ];
                        $Wxpush = new Wxpush();
                        $message = $Wxpush->getMessageDetail('orderPaySuccess', $replaceArr, $param);

                        if(!empty($message)){//调用接口
                            $param['first'] = $message['subject'];
                            $param['remark'] = $message['message'];

                            //$result = Api::callItemApi('Weixin', 'msgPush', ["memberId"=>$param['memberId'],"msgType"=>$flag,"msgJson"=>json_encode($param)]);

                            $result = $Wxpush->msgPush($param['memberId'], 'orderPaySuccess', json_encode($param));
                            //写日志
                            $data['param'] = ["memberId"=>$param['memberId'],"msgType"=>'orderPaySuccess',"msgInfo"=>$param];
                            $data['result'] = $result;
                            $datas = json_encode($data,JSON_UNESCAPED_UNICODE);
                            $datas = @mysql_escape_string($datas);
                            $modes_log = new OrderLogModel();
                            $modes_log->add(['type'=>'PUSH_WX_MSG','data'=>$datas,'status'=>1]);
                        }

                    }

                    header('Location: http://webapi.52ywy.com/App/weixin/html/user.paySccu.html');
                }
            }
            if($payTypeId==1){
                require(CORE_PATH.'Alipay/alipayapi.php');
            }
        }else{
            $op_model->where("order_id=$order_id")->delete();
            $this->ajaxReturn(['code'=>300,'msg'=>'下单失败']);
        }



        //写入订单日志
        //$orderLogModel = new OrderLogModel();
        //$orderLogModel->insertOneLog($member_id, "addressId:".$addressId."skuId".$cart_info['product_id'], "payTypeId:".$payTypeId);

    }


}
